<form class="layui-form" action="{:url()}" method="post" id="editForm">
    <div class="layui-form-item">
        <label class="layui-form-label">搜索用户</label>
        <div class="layui-input-inline">
            <input type="text" data-disabled class="layui-input field-nickname nickname" name="nickname" >
            <a onclick="javascript:serchUser();" class="layui-btn layui-btn-normal">搜索</a>
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">选择用户</label>
        <div class="layui-input-inline w200">
            <select name="uid" class="field-uid" type="select" lay-verify="required" id="users">
                <!-- <option value="0">无</option> -->
                {$user_options|raw}
            </select>
        </div>
    </div>
    <!-- <div class="layui-form-item">
        <label class="layui-form-label">批号数量</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input field-pihao_num" name="pihao_num">
        </div>
    </div> -->
    
    <div class="pop-bottom-bar hisi-footer">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit" lay-data="{pop: true, refresh: true}">提交保存</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
</form>
{include file="system@block/layui" /}
<script>
var s = "";
layui.use(['func'], function() {
    layui.func.assign({:json_encode($formData)});
});

layui.use(['form', 'layedit'], function () {
    var form=layui.form,layedit=layui.layedit;
    var index1 = layedit.build('LAY_demo1', {
            tool: ['strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right'],
            height: 200
        });
});



// 删除规格
$('#pihao').on('click', '.del', function() {

if ($('#pihao div label').length === 1) {
    layer.msg('只有一条不允许删除。', {
        time : 2000
    });
} else {
    //删除当前按钮所在的tr
    $(this).closest('div .layui-form-item').remove();
}
});

function serchUser(){
    var $ = layui.jquery;
    var form = layui.form
    var nickname = $(".nickname").val();
    if(!nickname){
        layer.alert('请输入用户姓名');
        return false;
    }
    $.ajax({
        url:"{:url('getOptions')}",
        data:{nickname:nickname},
        dataType:"json", //接口json格式
        success:function(data){
            var options = data.data;
            console.log(options);
            //添加到表格最后
            $('#users').html('');
            $('#users').append(options);
            form.render('select');
        },
        error:function(data){
            layer.alert(data.msg);
            // layer.alert(JSON.stringify(data), {
            //     title: data
            // });
        }
    });
}
</script>
<!--
/**
 * editor 富文本编辑器
 * @param array $obj 编辑器的容器ID
 * @param string $name [为了方便大家能在系统设置里面灵活选择编辑器，建议不要指定此参数]，目前支持的编辑器[ueditor,umeditor,ckeditor,kindeditor]
 * @param string $upload [选填]附件上传地址
 */
-->
{:editor(['UMeditor1', 'UMeditor2'])}
{:editor(['kindeditor1', 'kindeditor2'], 'kindeditor')}
{:editor(['UEditor1', 'UEditor2'], 'ueditor')}
{:editor(['ckeditor', 'ckeditor2'], 'ckeditor')}